package cn.iocoder.yudao.module.famous.doctor.dal.mysql.casehistory;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.casehistory.CaseHistoryDO;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.extraction.ExtractionDO;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.prescription.PrescriptionDO;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.treatmentuser.TreatmentUserDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.famous.doctor.controller.admin.casehistory.vo.*;
import org.apache.ibatis.annotations.Param;

import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * 我的病历 Mapper
 *
 * @author 档案
 */
@Mapper
public interface CaseHistoryMapper extends BaseMapperX<CaseHistoryDO> {

    default PageResult<CaseHistoryDO> selectPage(CaseHistoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CaseHistoryDO>()
                .eqIfPresent(CaseHistoryDO::getOthers, reqVO.getOthers())
                .betweenIfPresent(CaseHistoryDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(CaseHistoryDO::getIdentityCard, reqVO.getIdentityCard())
                .eqIfPresent(CaseHistoryDO::getNowIllnessHistory, reqVO.getNowIllnessHistory())
                .eqIfPresent(CaseHistoryDO::getOldIllnessHistory, reqVO.getOldIllnessHistory())
                .eqIfPresent(CaseHistoryDO::getHistoricalEpidemiology, reqVO.getHistoricalEpidemiology())
                .eqIfPresent(CaseHistoryDO::getHealthCheckup, reqVO.getHealthCheckup())
                .eqIfPresent(CaseHistoryDO::getUsagetype, reqVO.getUsagetype())
                .eqIfPresent(CaseHistoryDO::getDosage, reqVO.getDosage())
                .eqIfPresent(CaseHistoryDO::getDailyConsumption, reqVO.getDailyConsumption())
                .eqIfPresent(CaseHistoryDO::getMattersAttention, reqVO.getMattersAttention())
                .eqIfPresent(CaseHistoryDO::getUseBook, reqVO.getUseBook())
                .eqIfPresent(CaseHistoryDO::getCaseImages, reqVO.getCaseImages())
                .eqIfPresent(CaseHistoryDO::getTentativeDiagnosis, reqVO.getTentativeDiagnosis())
                .eqIfPresent(CaseHistoryDO::getInquiryId, reqVO.getInquiryId())
                .eq(CaseHistoryDO::getCreator, getLoginUserId())
                .orderByDesc(CaseHistoryDO::getId));
    }

    default List<CaseHistoryDO> selectList(CaseHistoryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CaseHistoryDO>()
                .eqIfPresent(CaseHistoryDO::getOthers, reqVO.getOthers())
                .betweenIfPresent(CaseHistoryDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(CaseHistoryDO::getIdentityCard, reqVO.getIdentityCard())
                .eqIfPresent(CaseHistoryDO::getNowIllnessHistory, reqVO.getNowIllnessHistory())
                .eqIfPresent(CaseHistoryDO::getOldIllnessHistory, reqVO.getOldIllnessHistory())
                .eqIfPresent(CaseHistoryDO::getUsagetype, reqVO.getUsagetype())
                .eqIfPresent(CaseHistoryDO::getDosage, reqVO.getDosage())
                .eqIfPresent(CaseHistoryDO::getDailyConsumption, reqVO.getDailyConsumption())
                .eqIfPresent(CaseHistoryDO::getMattersAttention, reqVO.getMattersAttention())
                .eqIfPresent(CaseHistoryDO::getUseBook, reqVO.getUseBook())
                .eqIfPresent(CaseHistoryDO::getHistoricalEpidemiology, reqVO.getHistoricalEpidemiology())
                .eqIfPresent(CaseHistoryDO::getHealthCheckup, reqVO.getHealthCheckup())
                .eqIfPresent(CaseHistoryDO::getCaseImages, reqVO.getCaseImages())
                .eqIfPresent(CaseHistoryDO::getTentativeDiagnosis, reqVO.getTentativeDiagnosis())
                .eqIfPresent(CaseHistoryDO::getInquiryId, reqVO.getInquiryId())
                .eq(CaseHistoryDO::getCreator, getLoginUserId())
                .orderByDesc(CaseHistoryDO::getId));
    }

    List<PrescriptionDO> selectPrescriptionContent();

    List<CaseHistoryDO>  selectAllByinquiryId(@Param("list") List<Long> inquiryRespVOS);
}
